#创建类
class Student(object):
    def __init__(self,name,age):
        self.name=name
        self.age=age
        self.__gender="男"
        return

    def getGender(self):
        return self.__gender

stu=Student("小明",20)
print(stu.name)
print(stu.age)
#相当于为stu新增了一个属性叫做__gender
stu.__gender="new name"
print(stu.getGender())


#获取对象类型
print(type('123'))
print(dir(stu))
print(dir(stu))

#限制累的属性个数
class Student(object):
    __slots__ = ('age','name')

    def __init__(self,name,age):
        self.age=age
        self.name='男'

s = Student('Bob', 59)
s.gender='男'


# 迭代dic
for x, y in {1: 1, 3: 9, 4: 16, 5: 25}.items():
    print("x:%d y:%d" % (x, y))

#列表生成式
v1 = [x + y for x in ['a', 'b', 'c'] for y in ['A', 'B', 'C']]
print(v1)

#生成器
v2=(x*y for x in[1,2,5] for y in [3,4,5])
for n in v2:
    print(n)